from django.shortcuts import render,HttpResponse
from .ana import ChipotleNan
from .import users_ana


REMOTE_HOST = "https://pyecharts.github.io/assets/js"

# Create your views here.

def index(request):

    index='''
        <h1>数据分析</h1>
        <hr />  
        <a href="1/">每种商品消售次数的bar图</a><br />
        <a href="2/">每种商品销售金额的bar图</a>
        <hr />
    '''
    request.session['user_name']="lishan"
    return render(request,'c2/bootcss.html')



def index1(request):

    chipo=ChipotleNan()

    bar=chipo.bar_how_many_are_sold_per_item()

    context=dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request,'c2/index.html', context)


def index2(request):

    chipo=ChipotleNan()

    bar=chipo.bar_how_much_are_sold_per_item()

    context=dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request,'c2/index.html', context)



def index3(request):

    info_obj=users_ana.UserAan_obj

    df=info_obj.df.head()

    print(df)

    return HttpResponse(df.to_json())

    
